const { defineConfig } = require('@vue/cli-service');
const path = require('path');

module.exports = defineConfig({
  transpileDependencies: true,
  productionSourceMap: false,
  publicPath: '/',
  devServer: {
    client: {
      overlay: false,
    },
    proxy: {
      '/v3/auth/tokens': {
        target: 'https://iam.myhuaweicloud.com/', // 代理目标的基础路径
        changeOrigin: true,
        pathRewrite: {}, // 重写路径
      },
      '/v1': {
        target: `https://cph.${process.env.VUE_APP_REGION}.myhuaweicloud.com/`, // 代理目标的基础路径
        changeOrigin: true,
        pathRewrite: {}, // 重写路径
      },
    },
  },
  configureWebpack: {},
  chainWebpack: config => {
    config.plugin('define').tap(args => {
      args[0]['process'] = { ...args[0]['process.env'] };
      return args;
    });
    config.output.path(path.join(__dirname, './dist')).filename('js/[name].js');
  },
});
